home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: scoshe@ix.netcom.com(Christopher Scott Shelton )
- Newsgroups: comp.lang.c
- Subject: HELP!! with file read/write
- Date: 18 Mar 1996 03:01:37 GMT
- Organization: Netcom
- Message-ID: <4iijmh$brs@cloner2.ix.netcom.com>
- NNTP-Posting-Host: atl-ga18-01.ix.netcom.com
- X-NETCOM-Date: Sun Mar 17 7:01:37 PM PST 1996
-
-
- This part of my program should read a record, decrease daysleft by one,
- and set today equal to zero and re-write the data at the original
- position.
- For some reason it does one read, the following write and then it exits
- out.
- I know that it should run 4 times. Can anyone help me with this
- problem.
-
- Thanks,
- Scott.....
- ---------------------------------
-
- void daily_maintainence()
- {
- FILE *itemfile;
- long filepos;
- struct _items item;
- itemfile=fopen("items.dat","r+b"); //open for read and write
- while (fread(&item,itemsize,1,itemfile)==1)
- {
- filepos=ftell(itemfile); //for debug
- item.today=0; //set to zero
- item.daysleft--; //decrement
- fseek(itemfile,-itemsize,SEEK_CUR); //seek to where this rec
- starts
- filepos=ftell(itemfile); //for debug
- fwrite(&item,itemsize,1,itemfile); //write it out
- filepos=ftell(itemfile); //for debug
- }
- }
- ------------------------
-
-
-
-
-